package com.pybox.api;

import com.pybox.aop.Mylog;
import com.pybox.common.utils.JdbcTemplateUtils;
import com.pybox.dto.Result;
import com.pybox.dto.TObjectsDto;
import com.pybox.entity.TChangNameDan;
import com.pybox.entity.TObjects;
import com.pybox.service.TGetShouQuanDanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author LeiYang
 * @title: TGetShouQuanDan
 * @projectName pybox
 * @description: TODO
 * @date 2019/8/516:47
 */

@RequestMapping("/TGetShouQuanDan")
@Api(tags = "TGetShouQuanDan")
@Slf4j
@RestController
public class TGetShouQuanDanApi {

    @Autowired
    private TGetShouQuanDanService tGetShouQuanDanService;

    @Autowired
    private JdbcTemplateUtils jdbcTemplateUtils;
    /**
     * 获取取件码申请单开始审核流程 ,更新改名申请单状态，启动流程实例，让启动的流程实例关联业务
     *
     * @param
     * @return
     */

    @ApiOperation(value = "改名申请单开始审核流程", notes = "改名申请单开始审核流程(申请单)")
    @RequestMapping(value = "/add", method = RequestMethod.PUT)
    @ApiImplicitParam(name = "id", value = "TChangNameDan id", dataType = "Integer", paramType = "path")
    @Mylog(value = "添加授权申请单")
    @ApiIgnore
    public Result<Boolean> add(@RequestBody TChangNameDan dto) {

        tGetShouQuanDanService.save(dto);
        //log.info(dto.toString());
        return Result.ok(true);
    }

    /**
     * 获取取件码申请单开始审核流程 ,更新改名申请单状态，启动流程实例，让启动的流程实例关联业务
     */
//    @ApiOperation(value = "改名申请单开始审核流程", notes = "改名申请单开始审核流程(申请单)")
//    @RequestMapping(value = "/startWorkflew", method = RequestMethod.PUT)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "taskId", value = "申请单 taskId", dataType = "Integer", paramType = "query"),
//            @ApiImplicitParam(name = "user_id", value = "下一步审核人ID", dataType = "Integer", paramType = "query")})
//    public Result<Boolean> startWorkflew(@RequestParam("id") Integer id,@RequestParam("user_id") Integer user_id) {
//        tGetShouQuanDanService.startWorkflew(id,user_id);
//        //log.info("::"+taskId+"::"+user_id);
//        return Result.ok(true);
//    }
    /**
     * 根据taskId处理这条信息
     */
    @ApiOperation(value = "根据taskId处理这条信息", notes = "根据taskId处理这条信息")
    @RequestMapping(value = "/dealDisagree", method = RequestMethod.GET)
    @Mylog(value = "处理申请任务")
    @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "path")
    public Result<Boolean> dealDisagree(@RequestParam("id") Integer id, @RequestParam("taskId") String taskId,@RequestParam("type") Integer type) {
        tGetShouQuanDanService.dealDisagree(id, taskId,type);
        return Result.ok(true);
    }

}
